import {
  createStore
} from 'vuex'

import createPersistedState from "vuex-persistedstate";  //安装cnpm install --save vuex-persistedstate

export default createStore({
  state: {
      userInfo: null,
  },
  mutations: {
      setUserInfo(state, data) {
          state.userInfo = data
      },

      setSignOut(state) {
          state.userInfo = null
      },

  },
  getters: {
      
  },
  actions: {
      userInfos({
          commit
      }, data) {
          commit("setUserInfo", data)
      },

      signOuts({
          commit
      }) {
          commit("setSignOut")
      },

  },
  modules: {},
  plugins: [
      createPersistedState({
          storage: window.localStorage,
          key: "store",
          render(state) {
              return {
                  ...state
              };
          }
      })
  ]
})
